package com.shxy.entity.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.shxy.util.converter.AbstractEnumConverter;
import com.shxy.util.converter.IEnum;
import org.springframework.lang.Nullable;

/**
 * 学历枚举
 */
public enum EducationEnum implements IEnum<String> {
    BOSHI("01", "全日制普通博士研究生"),
    SHUOSHI("02","全日制普通硕士研究生"),
    BENKE("04","全日制普通本科"),
    ZHUANKE("05","全日制普通专科（高职）"),
    CHENGREN("11","成人高考学历"),
    YUANCHENG("21","远程教育学历"),
    ZIKAO("31","自考学历"),
    DIANDA("41","国家开发大学"),
    QITA("13","其他学历")

    ;
    private String code;
    private String name;

    EducationEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return this.code;
    }

    public String getName() {
        return this.name;
    }

    /**
     * 类型转换器
     */
    public static class Converter extends AbstractEnumConverter<EducationEnum, String> {
        public Converter() {
            super(EducationEnum.class);
        }
    }


    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    @Nullable
    public static EducationEnum resolve(String name) {
        for(EducationEnum educationEnum: EducationEnum.values()) {
            if(name.equals(educationEnum.getName())){
                return educationEnum;
            }
        }
        return null;
    }
}
